package com.arelikebrothers.demo.concurrent.begin;

/**
 * Created by lennon on 30/04/2017.
 */
public class BadSuspend {
    public static Object obj = new Object();

    public static class ChangeObjectThread extends Thread {
        public ChangeObjectThread(String name) {
            super.setName(name);
        }

        @Override
        public void run() {
            System.out.println("in " + getName());
            Thread.currentThread().suspend();
        }
    }

    static ChangeObjectThread t1 = new ChangeObjectThread("t1");
    static ChangeObjectThread t2 = new ChangeObjectThread("t2");

    public static void main(String[] args) throws InterruptedException {
        t1.start();
        Thread.sleep(100);
        t2.start();

        t1.resume();
        t2.resume();

        t1.join();
        t2.join();
    }

}
